﻿@model List<thailandProject.ViewModel.PickupTasks>

@{

   ViewBag.Title = "View Pickup Tasks";

}

<div id="Wrapper2">

   <div id="content_header">

       <div id="headerimage">

       </div>

       <div id="theheader">@ViewBag.Header</div>

   </div>

   <!-- Left Column begins here -->

   <aside id="sidebar-wrapper">

       <nav class="sidebar">

           <!-- CONTENT GOES HERE -->

               

           @if (Model != null)

           {

               using (Html.BeginForm("ViewPickupTasks", "Reporting", FormMethod.Post, new { id = "searchForm" }))
               {
                 
                   <div id="searchDates" style="width:100%; margin-top:10px;">

                           <div class="search_box1"> From: <br /><input style="width:85%" type="text" class="datepickerGeneral" id="dateFrom" name="dateFrom" value="@ViewBag.from.ToShortDateString()" readonly="true" /></div>

                           <div class="search_box2"> To: <br /><input style="width:85%" type="text" class="datepickerGeneral" id="dateTo" name="dateTo" value="@ViewBag.to.ToShortDateString()" readonly="true" /></div>

                           <div class="search_button"><input id="searchButton" style="float:left;" type="image" alt="search" src="../../images/searchicon.png" /></div>

                           <div id="dateErrorMessage" style="color:red; visibility:hidden;">Please enter a "To" and "From" date.</div>

                   </div>

               }
               
               <div style="margin:15px 0px 0px 0px">
               <a id="printReport" href="javascript:void(0)"><div style="display:inline; float:left; margin:3px 5px 0px 10px; color:#cc7777;">View as </div><div style="display:inline;"><img src="../../images/pdf_icon.png" /></div></a>
               </div>
               <div id="mobileReport">
               @foreach (var r in Model)
               {
                   <div id="reportingHeader" onclick=" $(this).next(reportingBody).slideToggle('fast'); ">
                        <span id="propNameLabel" >@Html.DisplayFor(modelItem => r.propName)</span>

                        @Html.DisplayFor(modelItem => r.clientFirstName)
                        @Html.DisplayFor(modelItem => r.clientLastName)
                        <span id="mobileHeaderDate">@r.taskDueDate.ToString("M/d")</span>
                   
                   </div>
               
                    <div name="reportingBody" id="reportingBody" style="display:none"`>
                        @Html.Label("Task Due Date: ")
                        @r.taskDueDate.ToString("MMM dd, yyyy") <br />
                        @Html.Label("Task Name: ")
                        @Html.DisplayFor(modelItem => r.taskName)<br />
                        @Html.Label("Task Details: ") 
                        @Html.DisplayFor(modelItem => r.taskDetails)
                       
                    </div>
                    <br />
                   
               }
               </div>

               <div id="desktopReport">
               

               <table class="pickupTaskReport">

                      <tr>

                          <th>Property Name</th>

                          <th>First Name</th>

                          <th>Last Name</th>

                          <th>Due Date</th>

                          <th>Task Name</th>

                          <th>Task Details</th>

                      </tr>

               @foreach (var r in Model)
               {    

                   <tr>
                      
                       <td>@Html.DisplayFor(modelItem => r.propName)</td>  

                       <td id="fname">@Html.DisplayFor(modelItem => r.clientFirstName)</td>

                       <td id="lname">@Html.DisplayFor(modelItem => r.clientLastName)</td>

                       <td>@r.taskDueDate.ToString("MMM dd, yyyy")</td>

                       <td>@Html.DisplayFor(modelItem => r.taskName)</td>

                       <td>@Html.DisplayFor(modelItem => r.taskDetails)</td>          

                   </tr>

               }

               </table>
               </div>

           }

           else
           {

               <p>No Data Found!</p>

           }

       </nav>

       <!-- Left column ends here -->

   </aside>



</div>

<!-- Div wrapper2 ends here -->



<script>
    $(document).ready(function () {

        $("tr").not(':first').hover( function () {
            $(this).css("background", "#6ac3e0");
        }, function () {
                $(this).css("background", "");
            }
        );

        $("tr").not(':first').click(function () {
            $("#fnameinput").remove();
            $("#lnameinput").remove();
            fname = $(this).children("#fname").html();
            lname = $(this).children('#lname').html();
            var doit = window.confirm("Create a pickup poster for " + fname + " " + lname + "?");
            if (doit) {

                $("#searchForm").children().append('<input id="fnameinput" type="hidden" name="fname" value="' + fname + '" /><input id="lnameinput" type="hidden" name="lname" value="' + lname + '" />');
                $("#searchForm").attr("action", "/Reporting/printPickupTaskPDF");
                $("#searchForm").submit();
            }
        });


        $("#printReport").click(function () {
            $("#searchForm").attr("action", "/Reporting/printPickupTaskPDF");
            $("#searchForm").submit();
            $("#searchForm").attr("action", "/Reporting/ViewPickupTasks");
        });
    });
</script>